package com.wei.service_oss.controller;

import com.wei.service_oss.service.OssService;
import com.wei.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author wjx
 * @ClassName Osscontroller
 * @description: TODO
 * @date 2022-11-28 18:32
 * @version: 1.0
 */
@RestController
@RequestMapping("/eduoss/fileoss")
public class Osscontroller {

    @Autowired
    private OssService ossService;

    /**
     * 上传讲师头像
     *
     * @param file 获取上传文件
     * @return 上传到oss的路径
     */
    @PostMapping("/upload")
    public R upload(MultipartFile file) {

        String url = ossService.uploadAvatar(file);

        return R.ok().data("url", url);
    }

}
